using System;
using System.Collections;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;

using WHC.Pager.Entity;
using WHC.OrderWater.Commons;
using Microsoft.Practices.EnterpriseLibrary.Data;
using WHC.Hotel.Entity;
using WHC.Hotel.IDAL;

namespace WHC.Hotel.DAL
{
	/// <summary>
	/// ProtocolUnit 的摘要说明。
	/// </summary>
	public class ProtocolUnit : BaseDAL<ProtocolUnitInfo>, IProtocolUnit
	{
		#region 对象实例及构造函数

		public static ProtocolUnit Instance
		{
			get
			{
				return new ProtocolUnit();
			}
		}
		public ProtocolUnit() : base("KF_ProtocolUnit","Id")
		{
		}

		#endregion

		/// <summary>
		/// 将DataReader的属性值转化为实体类的属性值，返回实体类
		/// </summary>
		/// <param name="dr">有效的DataReader对象</param>
		/// <returns>实体类对象</returns>
		protected override ProtocolUnitInfo DataReaderToEntity(IDataReader dataReader)
		{
			ProtocolUnitInfo info = new ProtocolUnitInfo();
			SmartDataReader reader = new SmartDataReader(dataReader);
			
			info.Id = reader.GetInt32("Id");
			info.UnitName = reader.GetString("UnitName");
			info.UnitCode = reader.GetString("UnitCode");
			info.UnitType = reader.GetString("UnitType");
			info.UserName = reader.GetString("UserName");
			info.UserId = reader.GetInt32("UserId");
			info.IsAllowHang = reader.GetBoolean("IsAllowHang");
			info.HangAmount = reader.GetDecimal("HangAmount");
			info.Address = reader.GetString("Address");
			info.Remark = reader.GetString("Remark");
			info.ContactUser = reader.GetString("ContactUser");
			info.ContactPhone = reader.GetString("ContactPhone");
			info.HangMaxAmount = reader.GetDecimal("HangMaxAmount");
			info.OperatorUser = reader.GetString("OperatorUser");
			info.OperatorDate = reader.GetDateTime("OperatorDate");
			info.IsStop = reader.GetBoolean("IsStop");
			
			return info;
		}

		/// <summary>
		/// 将实体对象的属性值转化为Hashtable对应的键值
		/// </summary>
		/// <param name="obj">有效的实体对象</param>
		/// <returns>包含键值映射的Hashtable</returns>
        protected override Hashtable GetHashByEntity(ProtocolUnitInfo obj)
		{
		    ProtocolUnitInfo info = obj as ProtocolUnitInfo;
			Hashtable hash = new Hashtable(); 
			
 			hash.Add("UnitName", info.UnitName);
 			hash.Add("UnitCode", info.UnitCode);
 			hash.Add("UnitType", info.UnitType);
 			hash.Add("UserName", info.UserName);
 			hash.Add("UserId", info.UserId);
 			hash.Add("IsAllowHang", info.IsAllowHang);
 			hash.Add("HangAmount", info.HangAmount);
 			hash.Add("Address", info.Address);
 			hash.Add("Remark", info.Remark);
 			hash.Add("ContactUser", info.ContactUser);
 			hash.Add("ContactPhone", info.ContactPhone);
 			hash.Add("HangMaxAmount", info.HangMaxAmount);
 			hash.Add("OperatorUser", info.OperatorUser);
 			hash.Add("OperatorDate", info.OperatorDate);
 			hash.Add("IsStop", info.IsStop);
 				
			return hash;
		}

    }
}